package com.xudow.app.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Database helper
 *
 * @author lukecheng
 */
public class DatabaseHelper extends SQLiteOpenHelper {

    private static final String DB_NAME = "xd.db";
    private static final int DB_VERSION = 1;

    public DatabaseHelper(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        StringBuilder sql = new StringBuilder();
        sql.append("CREATE TABLE messages (");
        sql.append("    _id INTEGER PRIMARY KEY AUTOINCREMENT,");
        sql.append("    user_id INTEGER,");
        sql.append("    message_id INTEGER,");
        sql.append("    title TEXT,");
        sql.append("    content TEXT,");
        sql.append("    channel INTEGER,");
        sql.append("    create_time DATETIME,");
        sql.append("    status INTEGER,");
        sql.append("    is_system_msg INTEGER,");
        sql.append("    agency_name TEXT");
        sql.append(");");

        db.execSQL(sql.toString());
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }
}
